<div class="editcate_top">
		    <h2><?php echo $this->lang->line('add'); ?>:</h2>
		    <a href = "javascript:void(0)" onclick ="$('#light_adct').hide();$('#fade_adct').hide()"><img src="<?php echo base_url();?>public/admin/img/close.png" class="png" /></a>
</div>

<div id="div_message"></div>

		<form action="<?php echo  admin_url();?>/add-new-gallery" method="post" id="add-gallery-form" enctype="multipart/form-data">
			<div class="article_ct">
				<ul class="metatags">
			    	<li>
			        	<span class="left"><b><?php echo $this->lang->line('title'); ?>* : </b></span>
			            <span class="right"><input type="text" name="title" value="" style="width:100%;" id="add-name-page" /></span>
			        </li>
			        <li>
			        	<span class="left"><b><?php echo $this->lang->line('source'); ?>* :</b><i style="font-size: 10px; color:green;">(<?php echo $this->lang->line('required'); ?>: jpg, png, jpeg, gif & <?php echo $this->lang->line('size'); ?> 3MB)</i></span>
			            <span class="right" >
			            	<ul>
			            		<li>
			            			<input type="file" name="images_0"  value="" style="width: 250px;"/>
				            	</li>
				            	<li  id="add_more"><a href = "javascript:void(0)" onclick = "add_more_image('1');">Add more</a></li>
			            	</ul>
			            	
			            </span>
			        </li>
		            <li>
		                <span class="left"><b><?php echo $this->lang->line('parent'); ?>* : </b></span>
		                <?php if(count($cate)>0){?>
			                <span class="right">
			                	<select name="category" class="add-order" style="width: 150px;">
			                		<?php foreach ($cate as $k => $v){?>
			                		<option value="<?php echo $v->id;?>"><?php echo $v->name;?></option>
			                		<?php }?>
			                	</select>
			                </span>
		                <?php }?>
		            </li>
			    </ul>
			    <div class="btarticle">
			    	<input type="button" value="<?php echo $this->lang->line('cancel'); ?>" class="btn" onclick="reback()" />
			        <input type="submit" value="<?php echo $this->lang->line('save'); ?>" class="btn add-new-page" />
		    	</div>
			</div>
		</form>
<script type="text/javascript">
$('#add-gallery-form').iframer({
    onComplete: function(msg){
    	if(msg == 'yes') {
    		$('#light_adct').hide();$('#fade_adct').hide();
    		alert('<?php echo $this->lang->line('add_mess'); ?>');
            window.location	=	admin_url+'gallery';
    	}
    	else show_error('div_message', msg)
    }
});

function add_more_image(count){
	count = parseFloat(count) + 1;
	var new_image 	= '<li id = '+(parseFloat(count)-1)+'><input type="file"  name="images_'+(parseFloat(count)-1)+'" value="" style="width:85%;"/> </li>';
	var add_button	= '<a href="javascript:void(0)" onclick="add_more_image('+parseFloat(count)+')">Add more</a> <a style="margin:8px;" href="javascript:void(0)" onclick="close_image('+(parseFloat(count))+')">Close</a>';
	$('#add_more').before(new_image);
	$('#add_more').html(add_button);
}

function close_image(id){
	var identity	=	"#"+id;
	$(identity).remove();
	if(id >= 1){
		var idd   = id - 1;
		var count = id + 1;
		var add_button	= '<a href="javascript:void(0)" onclick="add_more_image('+(parseFloat(count)-1)+')">Add more</a> <a style="margin:8px; color:red;font-weight:bold;" href="javascript:void(0)" onclick="close_image('+(parseFloat(idd))+')">Close</a>';
		$('#add_more').html(add_button);
	}
	
}
function reback(){
	$('#light_adct').hide();$('#fade_adct').hide();
	window.location = admin_url+'gallery';
}
</script>